package my.yuan.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * @author: zhaoqiyuan
 * @description: HelloHystrix
 * @date: 2021/11/10 16:41
 */
public class HelloHystrix extends HystrixCommand<String> {
    protected HelloHystrix() {
        super(HystrixCommandGroupKey.Factory.asKey("test"));
    }
    @Override
    protected String run() throws Exception {
        Thread.sleep(5000);
        return "success";
    }
    @Override
    protected String getFallback() {
        System.out.println("fallback");
        return "error";
    }

    public static void main(String[] args) {
        HelloHystrix cmd = new HelloHystrix();
        String res = cmd.execute();
        System.out.println(res);

    }
}
